package com.pda.gongpin.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import com.pda.gongpin.R;
import com.pda.gongpin.bean.UnshelveBean;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;

import java.util.List;

public class UnshelveAdapter extends BaseAdapter<UnshelveBean> {
    OnChildCallClick onChildCallClick;
    public UnshelveAdapter(int layoutResId, @Nullable List<UnshelveBean> data) {
        super(layoutResId, data);
    }

    public OnChildCallClick getOnChildCallClick() {
        return onChildCallClick;
    }

    public void setOnChildCallClick(OnChildCallClick onChildCallClick) {
        this.onChildCallClick = onChildCallClick;
    }

    @Override
    protected void convert(BaseViewHolder helper, UnshelveBean item) {
        super.convert(helper, item);
        helper.setText(R.id.tv_title,item.getWareAreaName());
        RecyclerView recyclerView=helper.getView(R.id.rv_list);
        UnshelveListAdapter adapter=new UnshelveListAdapter(R.layout.item_unshelve_list,item.getWholePalletDetailVoList());
        recyclerView.setAdapter(adapter);
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter1, @NonNull View view, int position) {
                if (onChildCallClick != null){
                    onChildCallClick.onCallUp(item.getWholePalletDetailVoList().get(position));
                }
            }
        });
    }
    public interface OnChildCallClick{
        void onCallUp(UnshelveBean.WholePalletDetailVoListBean callUpDialog);
    }
}
